﻿using Ec_System.Models.Web;
using Ilongshi.Oversea.DataAccess;
using System.Collections.Generic;

namespace Ec_System.Service.Web
{
    public class CustomerAddressService
    {
        /// <summary>
        /// 根据LoginID获取客户的收货地址
        /// </summary>
        /// <param name="loginID"></param>
        /// <returns></returns>
        public List<CustomerAdressData> GetCustomerAdrListByLoginID(string loginID)
        {
            var cmd = DataCommandManager.GetDataCommand("GetUserAdrList");
            cmd.SetParameterValue("@LoginID", loginID);

            return cmd.ExecuteEntityList<CustomerAdressData>();
        }

        /// <summary>
        /// 增加地址
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddCustomerAdr(CustomerAdressData model)
        {
            var cmd = DataCommandManager.GetDataCommand("AddCustomerAdr");
            cmd.SetParameterValue("@LoginID", model.LoginID);
            cmd.SetParameterValue("@Province_ID", model.@Province_ID);
            cmd.SetParameterValue("@City_ID", model.@City_ID);
            cmd.SetParameterValue("@AdressMain", model.@AdressMain);
            cmd.SetParameterValue("@Zip", model.@Zip);
            cmd.SetParameterValue("@PhoneNum", model.@PhoneNum);
            cmd.SetParameterValue("@TelNum", model.@TelNum);
            cmd.SetParameterValue("@Town_ID", model.@Town_ID);
            cmd.SetParameterValue("@Recever", model.@Recever);

            return cmd.ExecuteNonQuery();
        }
    }
}
